package com.ct.deadlockdetetor.controller;

import com.ct.deadlockdetetor.common.controller.BaseController;
import com.ct.deadlockdetetor.common.pojo.CommonResult;
import com.ct.deadlockdetetor.common.pojo.TableDataInfo;
import com.ct.deadlockdetetor.domain.deadLock.dto.DeadLockMessageQueryDTO;
import com.ct.deadlockdetetor.service.DeadLockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dead/lock")
public class DeadLockController extends BaseController {

    @Autowired
    private DeadLockService deadLockService;

    /**
     * 查看死锁信息
     */
    @GetMapping("/list")
    public TableDataInfo list(DeadLockMessageQueryDTO deadLockMessageQueryDTO) {
        return getTableDataInfo(deadLockService.list(deadLockMessageQueryDTO));
    }

    /**
     * 删除进程
     */
    @DeleteMapping("/delete")
    public CommonResult<Void> delete(Integer processId) {
        return toCommonResult(deadLockService.delete(processId));
    }

}
